/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mrroman.linksender.gui.actions;

import com.mrroman.linksender.Configuration;
import com.mrroman.linksender.gui.*;
import com.mrroman.linksender.ioc.*;
import com.mrroman.linksender.sender.*;
import java.awt.event.ActionEvent;
import java.util.ResourceBundle;
import javax.swing.AbstractAction;

/**
 *
 * @author gorladam
 */
@Name("actions.ShowChatDialogAction")
public class ShowChatDialogAction extends AbstractAction {

    @Locales
    private ResourceBundle messages;
    @In
    private MessagePoint msgPoint;
    @In
    private Configuration config;

    @Init
    public void init() {
        putValue(NAME, messages.getString("chat_dialog"));
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        ChatDialog chatDialog = ObjectStore.getObject(ChatDialog.class);
        if (e != null && e.getSource() instanceof PopupLabel) {
            PopupLabel popupLabel = (PopupLabel) e.getSource();

            if (popupLabel.getMessage().getFlags() == Message.MESSAGE_FLAG_PRIVATE) {
                chatDialog.setSelectedUsers(popupLabel.getMessage().getSender());
            }
        }

        //msg.setSelectedUsers("dmn");
        chatDialog.setVisible(true);
    }
}
